var $;

function addInterface(){
    layui.use('layer', function(){
        var index = parent.layer.load(1, {
            shade: [0.3,'#000']
        });
        $.ajax({
            url:'/admin/interface/add',
            datatype:'json',
            data:{
                "serviceId":$('#select_service').val(),
                "uri":  $('#uri').val(),
                "memo":$('#memo').val()
            },
            success:function (res) {
                if(res.code == 0){
                    parent.layer.close(index);
                    parent.layer.close(top.interfaceId);
                    top.interfaceTable.reload();
                }
            },complete:function(res){

            }
        });
    });

}

layui.use( ['table','form','layer','jquery'], function () {
    $ = layui.jquery;

    //填充select数据
    var index = parent.layer.load(1, {
        shade: [0.3,'#000']
    });
    $.ajax({
        url:'/admin/interface/allService',
        datatype:'json',
        success:function (res) {
            if(res.code == 0){
                var dat = res.data;
                var options = '<option value="">全部</option>';
                for(var i = 0; i< dat.length; i++){
                    options += '<option value="' + dat[i].id + '">' + dat[i].serviceName + '</option>';
                }
                $('#select_service').html(options)
                layui.form.render('select');
            }
        },complete:function(res){
            parent.layer.close(index);
        }
    });

});





